<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Main.Master" Inherits="System.Web.Mvc.ViewPage<raya.Models.people.PersonSearchResult>" %>
<%@ Import Namespace="raya.Models.login"%>

<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Linq" %>
<%@ Import Namespace="raya.Library" %>
<asp:Content runat="server" ContentPlaceHolderID="MainContent" ID="c1">
    <b>Search Results</b><br />
    <br />
    <% if (!string.IsNullOrEmpty(ViewData.Model.error))
       { %>
    <b>
        <%= ViewData.Model.error%></b>
    <% }
       else
       {
           foreach (var result in ViewData.Model.results)
           {
               string thumb = "/images/people/" + result.id + ".jpg";
               var personid = result.id;
               if (!File.Exists(AppDomain.CurrentDomain.BaseDirectory + thumb))
               {
                   thumb = Utility.noPhotoThumbnailURL;
               }
               thumb = Img.by_size(thumb, 64, 64, false);
    %>
        <div class="friend">
            <div class="thumb">
                    <%= "<a href=\"/profile/" + result.id + "\">" +
								"<img src=\"" + thumb + "\" alt=\"" +
                                                result.name + 
								"\" title=\"" +
                                                result.name + 
								"\"/>" + "</a>" %>
            </div>
            <div class="fl padleft10">
            <div class="pad4">
                <b><%= "<a href=\"/profile/" + personid + "\">" + result.name + "</a>"%></b>
            </div>
                <div class="pad4">
                    <% if (Session["id"] != null && Session["id"].ToString() == personid)
                       {%>
                    <%= "<a href=\"" + RayaSettings.Web_prefix + "/profile/" + personid + "\">This is you</a><br />"%>
                    <% }
                       else if (ViewData.Model.friends.Contains<login>(result))
                       {%>
                    <%= "<a href=\"" + RayaSettings.Web_prefix + "/home/removefriend/" + personid + "\">Remove friend</a><br />"%>
                    <% }
                       else
                       {%>
                    <%= "<a href=\"" + RayaSettings.Web_prefix + "/home/addfriend/" + personid + "\">Add as friend</a><br />"%>
                    <%}%>
                    <%= "<a href=\"" + RayaSettings.Web_prefix + "/profile/" + personid + "\">View Profile</a>"%>
                </div>
            </div>
        </div>
        <div class="clear"></div>
        <%}
       }%>
</asp:Content>
